package com.funtonow.jqdk.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chaychan.viewlib.utils.StringUtils;
import com.funtonow.jqdk.R;
import com.funtonow.jqdk.bean.GameThirdInfoListBean;

import java.text.DecimalFormat;

/**
 * @author Jiajien
 * @date 2019/7/19
 */
public class HomeBannerAdapter extends BaseQuickAdapter<GameThirdInfoListBean, BaseViewHolder> {

    private DecimalFormat formatter = new DecimalFormat("0.00");// 格式化金额，保留两位小数

    public HomeBannerAdapter() {
        super(R.layout.item_home_banner);
    }

    @Override
    protected void convert(BaseViewHolder helper, GameThirdInfoListBean item) {

        String s = item.getFeilv() + " | " + item.getWeixin();
        helper.setText(R.id.tv_banner_loan_num, StringUtils.addComma(formatter.format(Double.parseDouble(String.valueOf(item.getEdumax())))))
                .setText(R.id.tv_banner_loan_lv, s);
        if (item.getVipfw() == 1) {
            helper.setText(R.id.tv_banner_loan_name, String.format(mContext.getResources().getString(R.string.vip_name), item.getName()));
        } else {
            helper.setText(R.id.tv_banner_loan_name, item.getName());
        }
        if (((helper.getAdapterPosition()+1) & 1) != 0) {
            helper.setBackgroundRes(R.id.ll_item_bg, R.mipmap.ic_home_banner1);
            helper.setTextColor(R.id.tv_loan_web, mContext.getResources().getColor(R.color.color_f03003));
        } else {
            helper.setTextColor(R.id.tv_loan_web, mContext.getResources().getColor(R.color.color_3480f0));
            helper.setBackgroundRes(R.id.ll_item_bg, R.mipmap.ic_home_banner2);
        }
    }

}
